#!/bin/bash

#------------------------------------------------------------------------------
#Filename:      84409-lvm.sh
#Version:       1.0
#Date:          2014/06/25
#Author:        xi.zhang
#Email:         xi.zhang@cs2c.com.cn
#Summary:       02.02系统管理功能-02逻辑卷管理-02字符命令-11创建raid4逻辑卷
#Notes:         创建raid4逻辑卷
#Copyright:     China Standard Software Co.,Ltd.
#History:
#               Version 1.0,2014/06/25
#               -The first one
#               Version 1.1,2014/10/22
#               -The second one
#               -Add SFROOT
#               -Rename variables 
#               -Add notes
#               -Add CleanData Function
#               -Add trap
#------------------------------------------------------------------------------

if [ -z "$SFROOT" ]
then
    CMDLIB=./
    SFROOT=./
else
    CMDLIB=${SFROOT}/testcases/Management_Function
fi

. ${SFROOT}/lib/UserOps.sh
. ${CMDLIB}/lib/Partition_parted.sh
. ${CMDLIB}/lib/PV.sh
. ${CMDLIB}/lib/VG.sh
. ${CMDLIB}/lib/LV.sh

IsRoot
EchoResult "脚本执行用户为root"

export PVNUM=5                           #物理卷数目
export VGNAME=vgroup-$$                  #卷组名称
export LVNAME=lvgroup-$$                 #逻辑卷名称
export LVSIZE=5                          #逻辑卷大小
export LVPATH=/dev/${VGNAME}/${LVNAME}   #逻辑卷路径
export STRIPE=4                          #stripe
export LVTYPE=raid4                      #逻辑卷类型

function CleanData()
{
  EchoInfo "Delete LV"
  DeleteLV

  EchoInfo "Delete VG"
  DeleteVG

  EchoInfo "Delete PV"
  DeletePV
}
trap CleanData INT EXIT
GetHarddisk

CreatePV
EchoResult "Step 1 :Create PV"

CreateVG
EchoResult "Step 2 :Create VG"

CreateRaidLV
EchoResult "Step 3 :Create Raid LV"

DeleteLV
EchoResult "Step 8 :Delete LV"

DeleteVG
EchoResult "Step 9 :Delete VG"

DeletePV
EchoResult "Step 10 :Delete PV"
